﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace List
{
    class GList<T>
    {
        private Node<T> head;
        private Node<T> tail;

        public GList()
        {
            tail = head = null;
        }
        public void Add(T t)
        {
            Node<T> a = new Node<T>(t);
            if (tail == null)
            {
                tail = head = a;
            }
            else
            {
                tail.Next = a;
                tail = a;
                tail.Next = null;
            }
        }
        public void ForEach(Action<T> action)
        {
            Node<T> p = head;
            while (p != null)
            {
                action(p.Data);
                p = p.Next;
            }
        }
    }
}
